package xyz.msj.hrm.properties;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import xyz.msj.hrm.RabbitMQApplication;

/**
 * 生产者
 */
@SpringBootTest(classes = RabbitMQApplication.class)
@RunWith(SpringRunner.class)
public class Producer05_topics_springboot {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Test
    public void testTopic(){

        for (int i = 0; i < 10; i++) {
            String message = "我来啦";
            rabbitTemplate.convertAndSend(RabbitMQConfig.QUEUE_NAME_EXCHANGE_TOPIC,"sms.xx",message);
            System.out.println("发送成功");
        }
    }

}
